from core.client import ClientHandlers
import sys
import requests
import json


class main_command(object):

    def __init__(self, sys_argv):
        self.sys_argv = sys_argv

        self.message = u"""
        Please input start or stop:
        start: argument start is start the monitor client. 
        stop:  argument stop is stop the monitor client.
        """

        if len(sys_argv) < 2:
            sys.exit(self.message)

        if self.sys_argv[1] == 'host_info':
            pass

        if self.sys_argv[1] == '':
            pass

    def send_request(self, url, method, data):
        headers = {"Content-type": "application/json"}

        res = None
        if method in ('get', "GET"):
            try:
                res = requests.get(url, data=json.dumps(data), headers=headers)
                return res
            except Exception as e:
                print(e)

        if method in ('post', 'POST'):
            try:
                res = requests.post(url, data=json.dumps(data), headers=headers)
                return res
            except Exception as e:
                print(e)

        return res

    def host_info(self):
        pass